package com.my.hzb.user.ctrl;


import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.my.hzb.common.bean.ResultBean;
import com.my.hzb.common.util.HttpUtil;
import com.my.hzb.entiy.Orders;
import com.my.hzb.entiy.UserInfo;
import com.my.hzb.order.service.OrderService;
import com.my.hzb.user.service.UserHttpServiceImpl;
import com.my.hzb.user.service.UserService;

@Controller
@RequestMapping("/count")
public class StatisticsCtrl {
	
	private static final Logger log = LogManager.getLogger(StatisticsCtrl.class);
	@Autowired
	private UserService userService;
//	@Autowired
//	private OrderService orderService;
	
//	交易金额
//	订单数量
//	商品数量
//	用户数量
	@RequestMapping("/count")
	@ResponseBody
	public ResultBean add(){
		ResultBean result = new ResultBean(ResultBean.RETURN_ERROR_CODE,ResultBean.RETURN_ERROR_MSG);
		try{
			UserInfo userSear = new UserInfo();
			userSear.setStatus(0);
			int userCount = userService.getCount(userSear);
			UserHttpServiceImpl userHttp = new UserHttpServiceImpl();
//			result.setReturnObj(new count(userCount,10,orderService.countByExample(new Orders()),orderService.countPrice(new Orders())));
			result.setReturnObj(new count(userCount,10,userHttp.countOrder(),userHttp.countOrderPrice()));
			result.setRespCode(ResultBean.RETURN_SUCCESS_CODE);
			result.setRespMsg("Ok");
		}catch(Exception e){
			log.error("统计错误",e);
		}
		return result;
	}
	class count{
		public count(){}
		public count(Integer userCount,Integer proCount,Integer orderCount,Double priceCount)
		{
			this.userCount = userCount;
			this.proCount = proCount;
			this.orderCount = orderCount;
			this.priceCount = priceCount;
		}
		private Integer userCount;
		private Integer proCount;
		private Integer orderCount;
		private Double priceCount;
		public Integer getUserCount() {
			return userCount;
		}
		public void setUserCount(Integer userCount) {
			this.userCount = userCount;
		}
		public Integer getProCount() {
			return proCount;
		}
		public void setProCount(Integer proCount) {
			this.proCount = proCount;
		}
		public Integer getOrderCount() {
			return orderCount;
		}
		public void setOrderCount(Integer orderCount) {
			this.orderCount = orderCount;
		}
		public Double getPriceCount() {
			return priceCount;
		}
		public void setPriceCount(Double priceCount) {
			this.priceCount = priceCount;
		}
		
	}
}
